package com.feidian.helper.ui;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.feidian.helper.R;

public class SettingActivity extends Activity {
	private TextView mTitle;
	private ImageView mBack;
	private LinearLayout mUpdate;
	private LinearLayout mFeedBack;
	private LinearLayout mModifyPass;
	private ViewGroup mAboutUs;
	private ViewGroup mChangePawword;
	private Dialog mDialog;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting);

		init();
	}

	private void init() {

		mTitle = (TextView) findViewById(R.id.title);
		mTitle.setText(getString(R.string.settings));
		mBack = (ImageView) findViewById(R.id.back);
		mAboutUs = (ViewGroup) findViewById(R.id.about_us);
		mAboutUs.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				startActivity(new Intent(SettingActivity.this,
						AboutActivity.class));
			}
		});

		mBack.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
			}
		});

		mUpdate = (LinearLayout) findViewById(R.id.update);
		mUpdate.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				mDialog = new Dialog(SettingActivity.this, R.style.dialog);
				LayoutInflater inflater = getLayoutInflater();
				View convertView = (View) inflater.inflate(R.layout.updatedown,
						null);
				Button okBn = (Button) convertView.findViewById(R.id.ok);
				okBn.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						mDialog.dismiss();
						Toast.makeText(SettingActivity.this, "目前已是最新版本",
								Toast.LENGTH_LONG).show();

					}
				});
				Button cancelBn=(Button)convertView.findViewById(R.id.cancel);
				cancelBn.setOnClickListener(new OnClickListener() {
					
					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						mDialog.dismiss();
					}
				});
				mDialog.setContentView(convertView);

				mDialog.show();
			}
		});
		mFeedBack = (LinearLayout) findViewById(R.id.feedback);
		mFeedBack.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				startActivity(new Intent(SettingActivity.this,
						FeedBackActivity.class));
			}
		});

		mModifyPass = (LinearLayout) findViewById(R.id.modify_pass);
		mModifyPass.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				Intent intent = new Intent(SettingActivity.this,
						ResetPasswordActivity.class);
				intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				startActivity(intent);
			}
		});
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}
}
